package com.anytron.config.timer;

import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean.StatefulMethodInvokingJob;

import com.anytron.model.AppTimer;
import com.anytron.service.CoreService;

public class AppTimerTask extends StatefulMethodInvokingJob {

	@Autowired
	CoreService coreService;
	
	@Override
	protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
		JobDataMap dataMap = context.getJobDetail().getJobDataMap();
		AppTimer appTimer = (AppTimer) dataMap.get("appTimer");
		coreService.executeTask(appTimer, 1);
	}
}
